import React, { Component } from 'react'
// 导入实例对象 new EventEmitter()
import eventbus from './myevents'
export default class Child2 extends Component {
    state = {
        username: ''
    }
    render() {
        return (
            <div>Child2--{this.state.username}</div>
        )
    };
    componentDidMount() {
        eventbus.on('myevent1', (data) => {
            console.log('data', data);
            this.setState({
                username: data
            })
        })
    }
}
